package com.talent.jiwen.util;

import android.content.Context;
import android.support.annotation.NonNull;
import android.view.View;

import com.afollestad.materialdialogs.DialogAction;
import com.afollestad.materialdialogs.MaterialDialog;
import com.talent.jiwen.R;
import com.talent.jiwen.ui.widgets.RemindDialog;
import com.talent.jiwen.ui.widgets.ResultDialog;

/**
 * Created by qyqx on 2018/8/14.
 */

public class MaterialDialogUtil {


    public static MaterialDialog.Builder getCommonDialog(Context mContext, String title, String content, String agree, String disagree, final OnDialogPoNeClickListener onDialogPoNeClickListener) {

        MaterialDialog.Builder dialog = new MaterialDialog.Builder(mContext)
                .title(title)
                .content(content)
                .positiveText(agree)
                .negativeText(disagree)
                .onPositive(new MaterialDialog.SingleButtonCallback() {
                    @Override
                    public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                        onDialogPoNeClickListener.onPositive();

                    }
                })
                .onNegative(new MaterialDialog.SingleButtonCallback() {
                    @Override
                    public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                        onDialogPoNeClickListener.onNegative();
                    }
                })
                .onAny(new MaterialDialog.SingleButtonCallback() {
                    @Override
                    public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                        LogUtil.e("onAny===" + which.toString());
                    }
                });

        return dialog;
    }


    /**
     * 开课提醒
     *
     * @param context
     * @param content
     * @param negative
     * @param positive
     * @param negativeListener
     * @param positiveListener
     * @return
     */
    public static RemindDialog getRemindDialog(Context context, int backgroudResId, String content, String negative, String positive
            , View.OnClickListener negativeListener, View.OnClickListener positiveListener) {

        RemindDialog remindDialog = new RemindDialog(context, backgroudResId, content, negative, positive
                , negativeListener, positiveListener);

        return remindDialog;
    }

    /**
     * 单个按钮的Dialog
     *
     * @param context
     * @param backgroudResId
     * @param content
     * @param positive
     * @param positiveListener
     * @return
     */
    public static RemindDialog getOneOptionRemindDialog(Context context, int backgroudResId, String content
            , String positive, View.OnClickListener positiveListener) {

        RemindDialog remindDialog = new RemindDialog(context, backgroudResId, content, positive, positiveListener);

        return remindDialog;
    }

    /**
     * 返回结果Dialog
     *
     * @param context
     * @param resId
     * @return
     */
    public static ResultDialog getResultDialog(Context context, int resId) {
        ResultDialog resultDialog = new ResultDialog(context, resId);
        resultDialog.setCancelable(false);

        return resultDialog;
    }


    public interface OnDialogPoNeClickListener {

        void onPositive();

        void onNegative();
    }

}
